package com.hlw.hr_man.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import net.sf.json.JSONObject;

import com.hlw.hr_man.Model.EmployeeModel;
import com.hlw.hr_man.service.FindCardService;
import com.hlw.hr_man.serviceImpl.FindCardServiceImpl;

public class FindCardcontroller extends HttpServlet{
	FindCardService fms = new FindCardServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		req.setCharacterEncoding("utf8");
		resp.setCharacterEncoding("utf8");
		JSONObject card = new JSONObject();
		PrintWriter pw = resp.getWriter();
		HttpSession session = req.getSession();
		int id = Integer.parseInt(req.getParameter("card"));
		card = fms.getCardCase(id);
		session.setAttribute("currentCard", card);
		pw.write(card.toString());
	}
}
